#include <stdio.h>
int main (void) 
{
	int o,p;
	scanf ("%d",&o);
	for (p=0;p<o;p++)
	{
		int a,b,c;
	scanf ("%d%d%d",&a,&b,&c);
	int x,m;
	m=0;
	for(x=1000;x<=9999;x++)
	{
		if (x%a==0&&(x+1)%b==0&&(x+2)%c==0)
		{
			printf ("%d\n",x);
			m++;
		}
	}
	if (m==0)
	{
		printf ("Impossible\n");
		m=0;
	}
	}
	return 0;
}
